home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '93 / Hacks '93 / HackTV & Example panel comp. / softVdig.h < prev   
Text File  |  1993-08-18  |  9KB  |  180 lines

  1. /*
  2.     File:        softVdig.c
  3.  
  4.     Contains:    Software video digitzer header file (constants, structs, prototypes)
  5.  
  6.     Written by:    Peter Hoddie (mostly) and Casey King and Gary Woodcock
  7.     
  8.                 Refer to develop Issue 14, "Video Digitizing Under QuickTime",
  9.                 for details on this code.
  10.                 
  11.                 This code requires QuickTime 1.5.
  12.  
  13.     Copyright:    © 1993 by Apple Computer, Inc.
  14.  
  15.     Change History (most recent first):
  16.  
  17. */
  18.  
  19. //-----------------------------------------------------------------------
  20. // includes
  21.  
  22. #ifndef    _SOFTVDIG_
  23. #define    _SOFTVDIG_
  24.  
  25. #include <Components.h>
  26. #include "QuickTimeComponents.h"
  27. #include <QDOffscreen.h>
  28.  
  29. // Comment out this line if you are building a standalone component
  30. #define DEBUG_IT
  31.  
  32. #ifdef DEBUG_IT
  33. pascal ComponentResult softVdig (ComponentParameters *params, Handle storage);
  34. Component RegisterSoftVdig(void);
  35. #endif DEBUG_IT
  36.  
  37.  
  38. // constants which define the characteristics of this vdig
  39. //    there are 2 other global controls which are initialized in vdigOpen
  40. //    these global controls are gAttachedGDevice and gAuxBufferRect
  41.  
  42. #define        kMaxHorNTSCIn         320                // maps to the MaxSrcRect width
  43. #define        kMaxVerNTSCIn         240                // maps to the MaxSrcRect height
  44. #define        kVerBlank            0                // would map to VerBlankRect, but unused here
  45. #define        gMaxSoftVdigCount      1                // how many can be open at once
  46. #define        gDoesDepths          0                // what output depth can the device output to
  47. #define        gDoesPlaythru          false            // will respond to VDSetPlayThruOnOff
  48. #define        gHasAuxBuffer          false            // simulates local buffering                                            
  49. #define        gAuxDepth              16                // for use in simulating local buffering                            
  50. #define        gCanAsync             true            // simulates async grab capability                
  51. #define        gCanClip              true            // clipping can be applied
  52. #define        gCanScale              true            // supports stretch & shrink
  53. #define        gCanDMA              true            // simulates the "go anywhere" vdig                        
  54. #define        gDMADepths          16 | 8            // depths that DMA works                
  55. #define        gMaxHeight          240                // maximum scalable height
  56. #define        gMaxWidth              320                // maximum scalable width
  57. #define        gMinHeight          10                // minimum scalable height
  58. #define        gMinWidth              10                // minimum scalable width
  59. #define        gDoesFrameRate      false            // simulates controllable frame rate grabs
  60. #define        gVideoTimeScale      2997            
  61. #define        gDoesCompress          false            // capable of producing compressed data            
  62. #define        gOnlyDoesCompress      false            // can't provide image data    
  63. #define        gOnlyCompressType      'rpza'            // set to zero to support all compression types
  64.  
  65. // softvdig global variables
  66.  
  67. typedef struct {
  68.     ComponentInstance    self;                    // this instance
  69.     long                frameNumber;            // frame counter
  70.     GWorldPtr            tempPort;                // use for drawing simulated video frames
  71.     Rect                maxSrcRect;                // for VDGetMaxSrcRect
  72.     Rect                digiRect;                // part of frame to use
  73.     Boolean                playThruOn;                // draw during idle
  74.     Rect                 playThruRect;
  75.     PixMapHandle        playThruPixMap;
  76.     GWorldPtr            auxBuffer;                // the auxbuffer, if using one
  77.     MatrixRecord        matrix;                    // display matrix
  78.     RgnHandle            clipRgn;                // current clip
  79.     Point                clipOrigin;                // top left of display when clip set
  80.     VdigBufferRecListHandle bufferList;            // buffer list for async stuff
  81.     short                pendingAsyncBuffer;        // pending grab request... -1 if none.
  82.  
  83.     // compressed source stuff
  84.     OSType                compressType;
  85.     short                compressDepth;
  86.     Rect                compressRect;
  87.     CodecQ                spatialQuality;
  88.     CodecQ                temporalQuality;
  89.     long                keyFrameRate;
  90.     ImageDescriptionHandle    desc;
  91.     Ptr                    compressBuffer;
  92.     GWorldPtr            compressGW;
  93.     Boolean                forceKeyFrame;
  94.     Boolean                compressOn;
  95.     ImageSequence        compressSeq;
  96.     TimeBase            timeBase;
  97.     TimeValue            nextFrameTime;            // next time if doing frame rate limiting
  98.     TimeValue            frameTimeStep;            // increment for stepping, non-zero means do limiting
  99.  
  100.     // more globals
  101.     long                inputCurrentFlags;
  102.     long                outputCurrentFlags;    
  103.     unsigned short        blackLevel;
  104.     unsigned short        whiteLevel;
  105.     unsigned short        brightness;
  106.     unsigned short        hue;
  107.     unsigned short        saturation;
  108.     unsigned short        contrast;
  109.     unsigned short        sharpness;
  110.     Rect                gAuxBufferRect;
  111.     GDHandle            gAttachedGDevice;
  112.  
  113. } vdigGlobalsRecord, *vdigGlobalsPtr, **vdigGlobals;
  114.  
  115. // prototypes that map to VD API calls
  116. pascal ComponentResult vdigOpen(vdigGlobals storage, ComponentInstance self);
  117. pascal ComponentResult vdigClose(vdigGlobals storage, ComponentInstance self);
  118. pascal ComponentResult vdigCanDo(vdigGlobals storage, short ftnNumber);
  119. pascal ComponentResult vdigVersion(vdigGlobals storage);
  120.  
  121. pascal VideoDigitizerError vdigGetMaxSrcRect(vdigGlobals storage, short inputStd, Rect *maxSrcRect);
  122. pascal VideoDigitizerError vdigGetActiveSrcRect(vdigGlobals storage, short inputStd, Rect *activeSrcRect);
  123. pascal VideoDigitizerError vdigSetDigitizerRect(vdigGlobals storage, Rect *digiRect);
  124. pascal VideoDigitizerError vdigGetDigitizerRect(vdigGlobals storage, Rect *digiRect);
  125. pascal VideoDigitizerError vdigUseThisCLUT(vdigGlobals storage, CTabHandle colorTableHandle);
  126. pascal VideoDigitizerError vdigGrabOneFrame(vdigGlobals storage);
  127. pascal VideoDigitizerError vdigSetContrast(vdigGlobals storage, unsigned short *contrast);
  128. pascal VideoDigitizerError vdigSetHue(vdigGlobals storage, unsigned short *hue);
  129. pascal VideoDigitizerError vdigSetBrightness(vdigGlobals storage, unsigned short *brightness);
  130. pascal VideoDigitizerError vdigSetSaturation(vdigGlobals storage, unsigned short *saturation);
  131. pascal VideoDigitizerError vdigSetSharpness(vdigGlobals storage, unsigned short *sharpness);
  132. pascal VideoDigitizerError vdigSetBlackLevel(vdigGlobals storage, unsigned short *blackLevel);
  133. pascal VideoDigitizerError vdigSetWhiteLevel(vdigGlobals storage, unsigned short *whiteLevel);
  134. pascal VideoDigitizerError vdigGetContrast(vdigGlobals storage, unsigned short *contrast);
  135. pascal VideoDigitizerError vdigGetHue(vdigGlobals storage, unsigned short *hue);
  136. pascal VideoDigitizerError vdigGetBrightness(vdigGlobals storage, unsigned short *brightness);
  137. pascal VideoDigitizerError vdigGetSaturation(vdigGlobals storage, unsigned short *saturation);
  138. pascal VideoDigitizerError vdigGetSharpness(vdigGlobals storage, unsigned short *sharpness);
  139. pascal VideoDigitizerError vdigGetBlackLevel(vdigGlobals storage, unsigned short *blackLevel);
  140. pascal VideoDigitizerError vdigGetWhiteLevel(vdigGlobals storage, unsigned short *whiteLevel);
  141. pascal VideoDigitizerError vdigGetVideoDefaults(vdigGlobals storage,
  142.                             unsigned short *blackLevel, unsigned short *whiteLevel,
  143.                             unsigned short *brightness, unsigned short *hue, unsigned short *saturation,
  144.                             unsigned short *contrast, unsigned short *sharpness);
  145. pascal VideoDigitizerError vdigGetMaxAuxBuffer(vdigGlobals storage, PixMapHandle *pm, Rect *r);
  146. pascal VideoDigitizerError vdigGetDigitizerInfo(vdigGlobals storage, DigitizerInfo *info);
  147. pascal VideoDigitizerError vdigGetCurrentFlags(vdigGlobals storage, long *inputCurrentFlag, long *outputCurrentFlag);
  148. pascal VideoDigitizerError vdigSetPlayThruOnOff(vdigGlobals storage, short state);
  149. pascal VideoDigitizerError vdigSetPlayThruDestination(vdigGlobals storage, PixMapHandle dest, Rect *destRect, MatrixRecord *m, RgnHandle mask);
  150. pascal VideoDigitizerError vdigSetupBuffers(vdigGlobals storage, VdigBufferRecListHandle bufferList);
  151. pascal VideoDigitizerError vdigPreflightDestination(vdigGlobals storage, Rect *digitizerRect, PixMap **dest, Rect *destRect, MatrixRecord *m);
  152. pascal VideoDigitizerError vdigGrabOneFrameAsync(vdigGlobals storage, short buffer);
  153. pascal long    vdigDone(vdigGlobals storage, short buffer);
  154. pascal VideoDigitizerError vdigGetNumberOfInputs(vdigGlobals storage, short *inputs);
  155. pascal VideoDigitizerError vdigGetInputFormat(vdigGlobals storage, short input, short *format);
  156. pascal VideoDigitizerError vdigSetInput(vdigGlobals storage, short input);
  157. pascal VideoDigitizerError vdigGetInput(vdigGlobals storage, short *input);
  158. pascal VideoDigitizerError vdigSetCompression(vdigGlobals storage, OSType compressType, short depth, Rect *bounds,
  159.             CodecQ spatialQuality, CodecQ temporalQuality, long keyFrameRate);
  160. pascal VideoDigitizerError vdigCompressOneFrameAsync(vdigGlobals storage);
  161. pascal VideoDigitizerError vdigCompressDone(vdigGlobals storage, Boolean *done, Ptr *theData, long *dataSize, unsigned char *similarity, TimeRecord *tr);
  162. pascal VideoDigitizerError vdigReleaseCompressBuffer(vdigGlobals storage, Ptr theBufffer);
  163. pascal VideoDigitizerError vdigGetImageDescription(vdigGlobals storage, ImageDescriptionHandle desc);
  164. pascal VideoDigitizerError vdigResetCompressSequence(vdigGlobals storage);
  165. pascal VideoDigitizerError vdigSetCompressionOnOff(vdigGlobals storage, Boolean newState);
  166. pascal VideoDigitizerError vdigGetCompressionTypes(vdigGlobals storage, VDCompressionListHandle h);
  167. pascal VideoDigitizerError vdigSetTimeBase(vdigGlobals storage, TimeBase t);
  168. pascal VideoDigitizerError vdigSetFrameRate(vdigGlobals storage, Fixed framesPerSecond);
  169. pascal VideoDigitizerError vdigGetDMADepths(vdigGlobals storage, long *depthArray, long *preferredDepth);
  170. pascal VideoDigitizerError vdigGetPreferredTimeScale(vdigGlobals storage, TimeScale *preferred);
  171.  
  172. // prototypes for utility functions
  173. void makeOffscreen(vdigGlobals storage);
  174. void tossOffscreen(vdigGlobals storage);
  175. void drawVideoFrame(vdigGlobals storage, Point where, PixMapHandle destPixMap);
  176. Boolean validatePixMap(vdigGlobals storage, PixMapHandle p);
  177. void tossCompressStuff(vdigGlobals storage);
  178.  
  179. #endif _MATHCOMPONENT_
  180.